<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/1/17 0017
  Time: 下午 3:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://"
      + request.getServerName() + ":" + request.getServerPort()
      + path + "/";
%>
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>${sessionScope.title}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  <link rel="stylesheet" href="/admin/css/x-admin.css" media="all">
</head>

<body>
<div class="x-body">

  <form action="" method="post" class="layui-form layui-form-pane">
    <div class="layui-form-item">
      <label for="name" class="layui-form-label">
        <span class="x-red">*</span>角色名
      </label>
      <div class="layui-input-inline">
        <input type="text" id="name" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input" value="${data.data.roleName}">
      </div>
    </div>
    <input type="hidden" name="rid" id="rid" value="${rid}">
    <div class="layui-form-item">
      <button class="layui-btn" lay-submit="" lay-filter="update">确认修改</button>
    </div>
  </form>
</div>
<script src="/admin/lib/layui/layui.js" charset="utf-8"></script>
<script src="/admin/js/x-layui.js" charset="utf-8"></script>
<script src="/admin/js/jquery.min.js" charset="utf-8"></script>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form()
            ,layer = layui.layer;


        //监听提交
        form.on('submit(update)', function(data){

            var name = $("#name").val();
            var rid = $("#rid").val();
            if(name=='' || name ==null){
                layer.msg('请填写角色');
                return false;
            }

            $.ajax({
                url:'/adminSystem/updateRole',
                type:'POST',
                data:{
                    name:name,
                    rid:rid
                },
                success:function(data){
                    if(data.data=='success'){
                        layer.msg('修改成功');
                    }else {
                        layer.msg('修改失败，请稍候再试');
                    }
                    setTimeout(function () { //2秒后刷新父页面
                        window.parent.location.reload();
                    }, 2000);
                }
            });
            return false;
        });

    });
    layui.use('element', function(){
        var $ = layui.jquery
            ,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块

    });
</script>
</body>

</html>